Preparing a Runtime Installation to use a Shadow Database

Description

This technique describes how to run the initial network optimization after a user installs a runtime application on his computer. It involves creating a "Bootstrap" application. Here is how to create a "Bootstrap" application.

  1. Create a dummy application with no tables, forms etc. The name of the dummy application must be the same as the "Master" application. E.g. "AutoPartsStore.adb"

  2. This dummy application will have a single Autoexec script shown below. (Alternatively, create a dummy table and then create a form for this dummy table. Put a button on this form and attach the code shown below to the OnPush event on this button. Set this form to be the startup form - using the File, Workspace Properties command.)

  3. Install the "Master" copy of the application in a shared folder on the server.

  4. Install the "Bootstrap" application on each runtime user's workstation.

  5. When the user starts the "Bootstrap" application (which in this example is called "AutoParts.adb" it will immediately display a dialog asking for the path to where the Master copy of "Autoparts.adb" is installed. Once the user fills this in and clicks the OK button, the script will automatically open the master copy of the database. It will then do the initial Network Optimize, and then open the shadow copy of the application on the user's machine.

Autoexec Script

The next time that the user opens "AutoParts.adb" on his machine he automatically is working with a network optimized version of the master database.

dim master_db_name as C
dim shadow_db_name as C
master_db_name = ""
shadow_db_name = ""
ui_modeless_dlg_box("Install MyAppName",<<%dlg%
{can_exit=exit}
{lf};
Specify the filename of the master copy of the application:;
[%P=ui_get_file("Select file","(*.adb)",master_db_name)%.100master_db_name];
{lf};
<Click Here to Start Install!oK?.not.(master_db_name="")> <Cancel!cancel>;
%dlg%,<<%code%
if a_dlg_button = "cancel" then
    ui_modeless_dlg_close("Install MyAppName")
    a_dlg_button = ""
end if
if a_dlg_button = "oK" then
    if file.exists(master_db_name) = .f. then
        ui_msg_box("Error", "Master Database not found.")
    else
        shadow_db_name = a5.Get_Name()
        a5.Load(master_db_name)
        a5_nopt_CopyAddFiles(shadow_db_name, master_db_name)
        create_shadow2(shadow_db_name, .t., .t.)
        ui_modeless_dlg_close("Install MyAppName")
    end if
end if
%code%)

Limitations

Desktop applications only. Not available in Community Edition.

See Also